home *** CD-ROM | disk | FTP | other *** search
/ Interplay's Learn to Program Basic (Review Copy) / Learn to Program Basic Review Copy (Interplay)(June 23, 1998).ISO / pc / ltpbasic / refxmpl / cointoss.bas < prev    next >
BASIC Source File  |  1998-03-09  |  633b  |  45 lines

  1. Dim A$ (2)
  2. Data Heads, Tails
  3. Let repeat = true
  4.  
  5. For I = 1 to 2
  6. Read A$(I)
  7. Next I
  8.  
  9. While repeat
  10.  
  11. choose:
  12. CLS
  13. Print  "Call it! Select a number for your" 
  14. Print "choice on the coin-toss"   
  15. Print "  1.  Heads"
  16. Print "  2.  Tails"
  17. Input guess
  18. If guess > 2 or guess < 1 then goto choose
  19. Print "You have selected ";
  20. Print A$(guess)
  21.  
  22. Let answer = Random (1,2)
  23.  
  24. Print "The toss is ";
  25. sleep 20
  26. Print A$(answer)
  27.  
  28. If guess=answer Then
  29. Print "You win!"
  30. Else Print "You lose!"
  31. Endif
  32.  
  33. Print "Want to play again?"
  34. Input answer$
  35. If Left$(answer$,1) <> "y" Then 
  36. repeat = false
  37. Endif
  38. Wend
  39.  
  40. Print "Thanks for playing."
  41. Print "Good-bye to you."
  42. End
  43.  
  44.